/**
 * 
 */
package demo.java.lang.management.vo;

/**
 * @author Administrator
 *
 */
public enum SpanType {
	SQL("sql","sql",1),
	CACHE("cache","cache",2),
	HTTP("http","http",3),
	LOG("log","log",4),
	METRIC("metric","metric",5),
	OSP("osp","osp",6),
	HTTP_SERVER("http_server","http_server",7),
	OSP_SERVER("osp_server","osp_server",8),
	REDIS("redis","redis",9),
	KAFKA("kafka","kafka",10),
	RABBITMQ("rabbitmq","rabbitmq",11),
	METHOD("method","method",12),
	THRIFTCLIENT("thriftclient","thriftclient",13),
	THRIFTSERVER("thriftserver","thriftserver",14),
	KV("kv","kv",15),
	MAINSTAY_CLIENT("mainstay_client","mainstay_client",16),
	MAINSTAY_SERVER("mainstay_server","mainstay_server",17);
	private String spanType;
	private String desc;
    private Integer value;

	SpanType(String spanType, String desc, Integer value) {
		this.spanType = spanType;
		this.desc = desc;
        this.value = value;
	}

	public String getSpanType() {
		return spanType;
	}


	public void setSpanType(String spanType) {
		this.spanType = spanType;
	}


	public String getDesc() {
		return desc;
	}

    public Integer getValue() {
        return value;
    }

    /**
	 * 
	 * @param type
	 * @return
	 */
	public static SpanType getEnum(String spanType) {
		for (SpanType orderStatus : SpanType.values()) {
			if (orderStatus.getSpanType().equalsIgnoreCase(spanType)) {
				return orderStatus;
			}
		}

		return null;
	}

    public static SpanType findByValue(int value){
        switch(value){
            case 1: return SQL;
            case 2: return CACHE;
            case 3: return HTTP;
            case 4: return LOG;
            case 5: return METRIC;
            case 6: return OSP;
            case 7: return HTTP_SERVER;
            case 8: return OSP_SERVER;
            default: return null;
        }
    }
}
